package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BusWaterItem;
import com.ruoyi.base.service.IBusWaterItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监测项基础信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-02
 */
@RestController
@RequestMapping("/base/wateritem")
public class BusWaterItemController extends BaseController
{
    @Autowired
    private IBusWaterItemService busWaterItemService;

    /**
     * 查询监测项基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterItem busWaterItem)
    {
        startPage();
        List<BusWaterItem> list = busWaterItemService.selectBusWaterItemList(busWaterItem);
        return getDataTable(list);
    }

    /**
     * 查询监测项基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:list')")
    @GetMapping("/distinctitemlist")
    public TableDataInfo DistinctItemlist(BusWaterItem busWaterItem)
    {
        startPage();
        List<BusWaterItem> list = busWaterItemService.DistinctItemlist(busWaterItem);
        return getDataTable(list);
    }

    /**
     * 导出监测项基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:export')")
    //@Log(title = "监测项基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterItem busWaterItem)
    {
        List<BusWaterItem> list = busWaterItemService.selectBusWaterItemList(busWaterItem);
        ExcelUtil<BusWaterItem> util = new ExcelUtil<BusWaterItem>(BusWaterItem.class);
        util.exportExcel(response, list, "监测项基础信息数据");
    }

    /**
     * 获取监测项基础信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:query')")
    @GetMapping(value = "/getinfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busWaterItemService.selectBusWaterItemById(id));
    }

    /**
     * 新增监测项基础信息
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:add')")
    //@Log(title = "监测项基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusWaterItem busWaterItem)
    {
        return toAjax(busWaterItemService.insertBusWaterItem(busWaterItem));
    }

    /**
     * 修改监测项基础信息
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:edit')")
    //@Log(title = "监测项基础信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody BusWaterItem busWaterItem)
    {
        return toAjax(busWaterItemService.updateBusWaterItem(busWaterItem));
    }

    /**
     * 删除监测项基础信息
     */
    //@PreAuthorize("@ss.hasPermi('base:wateritem:remove')")
    //@Log(title = "监测项基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busWaterItemService.deleteBusWaterItemByIds(ids));
    }


}
